<%--***************************************
*
*PayPal
* 
***************************************--%>
<%@ page import="
	java.util.*,
	java.text.*,
	com.probiz.estore.common.model.order.SalesOrder,
	com.probiz.estore.common.model.system.PaymentGateway,
	com.probiz.estore.common.helper.ConfigUtil"
	contentType="text/html; charset=UTF-8"%>
<%

	SalesOrder salesOrder = (SalesOrder) request.getAttribute("salesOrder");
	PaymentGateway paymentGateway = (PaymentGateway) request.getAttribute("paymentGateway");
	request.setAttribute("paymentGateway",paymentGateway);
	HashMap paramMap = paymentGateway.getConfigData();
	
	//-----------------------start: 账户信息------------------------------------------
	String business ="";
	String currency_code="";
	String type="";
	if (paramMap != null) {
		business = paramMap.get("business").toString().trim(); 				//商家
		currency_code = paramMap.get("currency_code").toString().trim(); 	//币种
		type = paramMap.get("type").toString().trim(); 						//接入模式
	}
	//-----------------------end:   账户信息------------------------------------------
	
	//-----------------------start: 配置信息------------------------------------------
	String returnURL=ConfigUtil.getInstance().getStoreFrontSiteUrl()+"/system/payment/paypal_response.html";  //页面跳转通知页面
	String cancelURL=ConfigUtil.getInstance().getStoreFrontSiteUrl()+"/cart/shoppingcart.html";					 //
	
	//-----------------------end:   配置信息------------------------------------------
	
	//-----------------------start:	业务信息------------------------------------------
	DecimalFormat df = new DecimalFormat("0.00");
	String amount = df.format(salesOrder.getUnPaidAmount().doubleValue()); //要支付的订单总价
	String orderNo = salesOrder.getOrderNo();
	
	String requestUrl="";			//提交地址
	if(type.equals("1")){
		requestUrl="https://www.paypal.com/cgi-bin/webscr";
	}else{
		requestUrl="https://www.sandbox.paypal.com/cgi-bin/webscr";
	}
	//-----------------------end:	业务信息------------------------------------------
	
 %>

<div style="display:none;">
	<form name="paymentGatewayForm" action="<%=requestUrl%>" method="post">
		<input type=hidden name="amount" value="<%=amount%>">
		<input type=hidden name="item_name" value="orderNo:<%=orderNo%>">
		<input type=hidden name="charset" value="UTF-8">									<%--字符编码--%>
		<input type=hidden name="cmd" value="_ext-enter">									<%--提交模式--%>
		<input type=hidden name="redirect_cmd" value="_xclick">		
		<input type=hidden name="custom" value="<%=orderNo%>">
		<input type=hidden name="invoice" value="invoiceNo:<%=orderNo%>">
		<input type=hidden name="rm" value="2">	
		<input type=hidden name="business" value="<%=business%>">	
		<input type=hidden name="currency_code" value="<%=currency_code%>">
		<input type=hidden name="return" value="<%=returnURL%>">
		<input type=hidden name="notify_url" value="<%=returnURL %>">
		<input type=hidden name="cancel_return" value="<%=cancelURL%>">
	</form>
</div>
	
	
<script type="text/javascript">
$j(document).ready(function () {
	document.forms["paymentGatewayForm"].submit();
});
</script>

<%@ include file="./include/payOrderTips.jspf" %>